<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2016-10-15
 * Time: 17:10
 */

namespace app\src\user\model;


use think\Model;

class UcenterMember extends Model
{
    /**
     * 邮箱注册的
     * 4
     */
    const ACCOUNT_TYPE_EMAIL = "4";
    /**
     * 手机注册的
     * 3
     */
    const ACCOUNT_TYPE_MOBILE = "3";
    /**
     * 用户名注册
     * 1
     */
    const ACCOUNT_TYPE_USERNAME = "1";

    protected $auto = ['last_login_time', 'last_login_ip'];
    protected $insert = ['status' => 1, 'reg_time' => 0, 'reg_ip' => 0];
    protected $update = ['update_time'];

    protected function setUpdateTimeAttr()
    {
        return time();
    }

    protected function setLastLoginIpAttr()
    {
        return ip2long(request()->ip());
    }

    protected function setLastLoginTimeAttr()
    {
        return time();
    }

    protected function setRegIpAttr()
    {
        return ip2long(request()->ip());
    }


    protected function setRegTimeAttr()
    {
        return time();
    }

    protected function getStatusDescAttr()
    {
        $status = ['-1' => '已删除', '1' => '正常', '2' => '正在审核中', '0' => '禁用'];
        return $status[$this->getData('status')];
    }
}